<?php
class Techstack extends AppModel
{
	var $name = 'Techstack';
    var $primaryKey = 'id'; 
    var $hasOne = array(
		'TechPerson' => array(
		'className' => 'TechPerson',
		'dependent' => true
		),
		'TechEconomic' => array(
		'className' => 'TechEconomic',
		'dependent' => true
		),
		'TechPatent' => array(
		'className' => 'TechPatent',
		'dependent' => true
		),
		'TechDevelopmentCost' => array(
		'className' => 'TechDevelopmentCost',
		'dependent' => true
		),
	); 
    function getValue($flag=null,$type=null)
    {
    	$objTechstack=$this->findAll($type,"Techstack.id,Techstack.name","Techstack.modified desc");
    	$options=array();
    	if($flag){
    		$options['']="请选择类型";
	    }
	    foreach ($objTechstack as $objtype){
	 		$options[$objtype['Techstack']['id']]=$objtype['Techstack']['name'];
	    }
	    return $options;
    }
    
    function getMenu($html,$tech,$actions,$controller,$pagename,$type=1,$pagefilter="settechfilter"){
    	$objmenu=$this->getValue(null,"Techstack.type='".$type."'");
    	$objmenu[$pagefilter]="自定义条件";
    	if(($actions=="index" || $actions=="showtechnology") && $type==1){
    		echo '<ul>';
    	}else if(($actions=="talentdb" || $actions=="showtalent") && $type==2){
    		echo '<ul>';
    	}else if(($actions=="allfinace" || $actions=="showfinacedetail") && $type==3){
    		echo '<ul>';
    	}else if($pagefilter==$actions){
    		echo '<ul>';
    	}else{
    		echo '<ul style="display:none;">';
    	}
        $cll=strtolower($controller);
        if($objmenu){     
	        foreach($objmenu as $key=>$menu)
			{  
				 $selected="";
				 if(!empty($tech)){
					 if($key==$tech){
					 	$selected = "selected";
					 }
				 }
				 $url='/'.$cll.'/'.$pagename.'/'.$key;
				 if($menu=="自定义条件"){
				 	 $url='/'.$cll.'/'.$pagefilter;
					 if($key==$actions && empty($tech)){
					 	$selected = "selected";
					 }
				 }
				 echo '<li>';
				 echo $html->link($menu,$url,array("class"=>$selected));
				 echo '</li>';
			}
        } 
        echo '</ul>';
    }
    function getTName($id)
    {
    	$objTechstack=$this->findById($id,"`Techstack`.`id`, `Techstack`.`name`");
    	$tname=$objTechstack['Techstack']['name'];
    	if(empty($tname)){
    		$tname= '&nbsp;';
    	}
    	return $tname;
    }
}
?>